// source --> http://ashoksawhney.com/wp-content/plugins/ultimate-lightbox/assets/js/ultimate-lightbox.js?ver=1.0.0 /* Simple JavaScript Inheritance * By John Resig http://ejohn.org/ * MIT Licensed. */ // Inspired by base2 and Prototype (function(){ var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; // The base Class implementation (does nothing) this.Class = function(){}; // Create a new Class that inherits from this class Class.extend = function(prop) { var _super = this.prototype; // Instantiate a base class (but only create the instance, // don’t run the init constructor) initializing = true; var prototype = new this(); initializing = false; // Copy the properties over onto the new prototype for (var name in prop) { // Check if we’re overwriting an existing function prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn) { return function() { var tmp = this._super; // Add a new ._super() method that is the same method // but on the super-class this._super = _super[name]; // The method only need to be bound temporarily, so we // remove it when we’re done executing var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } // The dummy class constructor function Class() { // All construction is actually done in the init method if ( !initializing && this.init ) this.init.apply(this, arguments); } // Populate our constructed prototype object Class.prototype = prototype; // Enforce the constructor to be what we expect Class.prototype.constructor = Class; // And make this class extendable Class.extend = arguments.callee; return Class; }; })(); var lightbox; //Finger Swipe Method 1 var slider = { // // The elements. // el: { // slider: jQuery(".ewd-ulb-slide-area"), // holder: jQuery(".ewd-ulb-slide-container"), // imgSlide: jQuery(".ewd-ulb-image-displaying img") // }, // The stuff that makes the slider work. slideWidth: jQuery(".ewd-ulb-slide-container").width(), // Calculate the slider width. // Define these as global variables so we can use them across the entire script. touchstartx: undefined, touchmovex: undefined, movex: undefined, index: 0, longTouch: undefined, // init: function() { // this.bindUIEvents(); // }, // bindUIEvents: function(){ // }, }; var defaults = { custom_css: '', transition_class: 'ewd-ulb-horizontal-slide', speed: 600, height: '100%', width: '100%', closable: true, loop: true, keyboard_controls: true, show_thumbnails: 'bottom', show_thumbnail_toggle: true, curtain_slide: false, hide_elements: ['description', 'thumbnails'], autoplay: false, autoplay_interval: 4000, show_progress_bar: false, mousewheel_navigation: true, zoomLevel: 0, fullsize: false, ulb_arrow: 'a', ulb_icon_set: 'a', controls: {'top_right_controls': ['exit'], 'top_left_controls': ['autoplay', 'zoom', 'zoom_out', 'download', 'fullscreen'], 'bottom_right_controls': ['slide_counter'], 'bottom_left_controls': []} }; var EWD_ULB_LightboxSlide = Class.extend({ init: function(element, length) { this.element = element; this.source = jQuery(element).data("ulbsource"); this.title = jQuery(element).data("ulbtitle"); this.description = jQuery(element).data("ulbdescription"); this.gallery = jQuery(element).data("ulbGallery"); if (this.source) { var youtube = this.source.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i); if (youtube) { this.video = "youtube"; this.source = this.source.replace("watch?v=", "embed/"); } else { this.video = false; } } else { this.video = false; } if (jQuery(element).data("ulbheight")) {this.height = jQuery(element).data("ulbheight");} else {this.height = 315;} if (jQuery(element).data("ulbwidth")) {this.width = jQuery(element).data("ulbwidth");} else {this.width = 560;} } }); var UltimateLightbox = Class.extend({ init: function(options) { this.settings = jQuery.extend({}, defaults, options); this.displaying = false; var elements = []; jQuery('.ewd-ulb-lightbox, .ewd-ulb-lightbox-noclick-image').each(function(index, value) { var Slide = new EWD_ULB_LightboxSlide(this, elements.length); jQuery(this).data('slideIndex', elements.length); elements.push(Slide); }); this.elements = elements; this.currentSlide = 0; this.maxSlide = this.elements.length - 1; this.setMobileClasses(); if (this.settings.curtain_slide) { this.getPairedImages(); } }, getPairedImages: function() { var sources = []; jQuery(this.elements).each(function(index, element) { sources.push(element.source); }); var data = 'image_sources=' + JSON.stringify(sources) + '&action=ulb_get_paired_images'; jQuery.post(ajaxurl,data, function(response) { var paired_images = jQuery.parseJSON(response); jQuery.each(paired_images, function(index, element) { if(element != "") // If a pair exists { //Wrapping img with 20-20 img_height = paired_images.height; var bef_img = jQuery('.ewd-ulb-slide-img').children("img[src='"+ index + "']"); bef_img.wrap( "
"); bef_img.after(""); //jQuery('.twentytwenty-container').twentytwenty(); } }); }); }, setMobileClasses: function() { if (jQuery.inArray('description', this.settings.hide_elements) !== -1) {this.settings.descriptionClass = 'ewd-ulb-mobile-hide';} else {this.settings.descriptionClass = '';} if (jQuery.inArray('title', this.settings.hide_elements) !== -1) {this.settings.titleClass = 'ewd-ulb-mobile-hide';} else {this.settings.titleClass = '';} if (jQuery.inArray('thumbnails', this.settings.hide_elements) !== -1) {this.settings.thumbnailsClass = 'ewd-ulb-mobile-hide';} else {this.settings.thumbnailsClass = '';} if (this.settings.descriptionClass == 'ewd-ulb-mobile-hide' && this.settings.titleClass == 'ewd-ulb-mobile-hide') {this.settings.overlayClass = 'ewd-ulb-mobile-hide';} else {this.settings.overlayClass = '';} }, setCurrentSlide: function(targetElement) { jQuery(this.elements).each(function(index, element) { if (element.source == jQuery(targetElement).data('ulbsource')) {lightbox.currentSlide = index;} }) }, toggle: function() { if (this.displaying) {this.closeLightbox();} else {this.openLightbox();} }, closeLightbox: function() { //if oldSlide is a video Stop playing var checkForVid = jQuery(".ewd-ulb-active-slide.ewd-ulb-image-displaying") if(checkForVid.find('iframe').length > 0) { if (checkForVid.find('iframe').attr('src').indexOf("autoplay") != -1) { checkForVid.find('iframe').attr('src', checkForVid.find('iframe').attr('src').replace('?autoplay=1','')); } else { checkForVid.find('iframe').attr('src', checkForVid.find('iframe').attr('src')); } } this.displaying = false; jQuery('.ewd-ulb-background').css('display', 'none'); jQuery('.ewd-ulb-lightbox-container').css('display', 'none'); // jQuery('.ewd-ulb-background').css('visibility', 'hidden'); // jQuery('.ewd-ulb-lightbox-container').css('visibility', 'hidden'); this.switchSlide(); jQuery('.ewd-ulb-active-slide').removeClass('ewd-ulb-active-slide'); jQuery('.ewd-ulb-active-thumbnail').removeClass('ewd-ulb-active-thumbnail'); }, openLightbox: function () { this.displaying = true; jQuery('.ewd-ulb-background').css('display', 'inline'); jQuery('.ewd-ulb-lightbox-container').css('display', 'inline'); if ( this.settings.autoplay ) {this.startAutoplay();} //For each image check if Iframe exists jQuery('.ewd-ulb-slide-img').each(function(){ var thisSlideImg = jQuery(this); if(thisSlideImg.find('iframe').length > 0) // If it is a video { thisSlideImg.find('iframe').css('height', 'calc(100% - 40px)'); thisSlideImg.find('iframe').css('max-width', 'calc(100% - 40px)'); } }); this.switchSlide(); this.selectThumbnails(); lightbox.noZoom(); //To check If the current image is a frame. var checkForVid = jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying'); if(checkForVid.find('iframe').length > 0) { //console.log('check for vide0'); // To autoplay video if (checkForVid.find('iframe').attr('src').indexOf("autoplay") == -1) { checkForVid.find('iframe').attr('src', checkForVid.find('iframe').attr('src') + '?autoplay=1'); } } // Finger Swipe Method 2(slick) //jQuery('.ewd-ulb-slide-img').slick(); }, enlargeImage: function () { // Fetch the size of the window // make the image full size by updating height and width. this.displaying = true; jQuery('.ewd-ulb-background').css('display', 'inline'); jQuery('.ewd-ulb-lightbox-container').css('display', 'inline'); if ( this.settings.autoplay ) {this.startAutoplay();} this.switchSlide(); this.selectThumbnails(); lightbox.noZoom(); }, nextSlide: function() { var oldSlide = this.currentSlide; do { //if (this.currentSlide == this.maxSlide && ewd_ulb_php_data.gallery_loop == "false" ) {return;} // else {this.currentSlide = this.currentSlide + 1;} // } // while (this.elements[oldSlide].gallery != this.elements[this.currentSlide].gallery); // jQuery('.ewd-ulb-slide').addClass('ewd-ulb-transition-next'); // this.switchSlide(oldSlide); //To check for loop on/off // console.log("From next slide fn" + this.maxSlide); if(this.currentSlide != this.maxSlide) { this.currentSlide = this.currentSlide + 1; } else if (this.currentSlide == this.maxSlide && ewd_ulb_php_data.gallery_loop) { if(this.maxSlide == 0){ return; } this.currentSlide = 0; } else if(this.currentSlide == this.maxSlide && ! ewd_ulb_php_data.gallery_loop) { return; } }while (this.elements[oldSlide].gallery != this.elements[this.currentSlide].gallery); jQuery('.ewd-ulb-slide').addClass('ewd-ulb-transition-next'); this.switchSlide(oldSlide); //if oldSlide is a video Stop playing it var checkForVid = jQuery(".ewd-ulb-slide[data-slideindex='" + oldSlide + "']"); if(checkForVid.find('iframe').length > 0) { if (checkForVid.find('iframe').attr('src').indexOf("autoplay") != -1) { checkForVid.find('iframe').attr('src', checkForVid.find('iframe').attr('src').replace('?autoplay=1','')); return false; } else { checkForVid.find('iframe').attr('src', checkForVid.find('iframe').attr('src')); return false; } } }, previousSlide: function() { var oldSlide = this.currentSlide; do { // if (this.currentSlide == 0) {this.currentSlide = this.maxSlide;} // else {this.currentSlide = this.currentSlide - 1;} // } // while (this.elements[oldSlide].gallery != this.elements[this.currentSlide].gallery); // jQuery('.ewd-ulb-slide').addClass('ewd-ulb-transition-previous'); // this.switchSlide(oldSlide); // console.log("From previous slide fn" + this.maxSlide); if(this.currentSlide != 0 ) { this.currentSlide = this.currentSlide - 1; } else if (this.currentSlide == 0 && ewd_ulb_php_data.gallery_loop) { if(this.maxSlide == 0){ return; } this.currentSlide = this.maxSlide; } else if(this.currentSlide == 0 && ! ewd_ulb_php_data.gallery_loop) { return; } }while (this.elements[oldSlide].gallery != this.elements[this.currentSlide].gallery); jQuery('.ewd-ulb-slide').addClass('ewd-ulb-transition-previous'); this.switchSlide(oldSlide); //if oldSlide is a video Stop playing var checkForVid = jQuery(".ewd-ulb-slide[data-slideindex='" + oldSlide + "']"); if(checkForVid.find('iframe').length > 0) { if (checkForVid.find('iframe').attr('src').indexOf("autoplay") != -1) { checkForVid.find('iframe').attr('src', checkForVid.find('iframe').attr('src').replace('?autoplay=1','')); return false; } else { checkForVid.find('iframe').attr('src', checkForVid.find('iframe').attr('src')); return false; } } }, goToSlide: function(slideIndex) { var oldSlide = this.currentSlide; this.currentSlide = slideIndex; jQuery('.ewd-ulb-slide').addClass('ewd-ulb-transition-next'); this.switchSlide(oldSlide); }, switchSlide: function(oldSlide) { if (typeof oldSlide !== "undefined") { jQuery(".ewd-ulb-slide-thumbnail[data-slideindex='" + oldSlide + "']").removeClass('ewd-ulb-active-thumbnail'); jQuery(".ewd-ulb-slide[data-slideindex='" + oldSlide + "']").removeClass('ewd-ulb-image-displaying') jQuery(".ewd-ulb-slide[data-slideindex='" + oldSlide + "']").addClass('ewd-ulb-old-active-slide'); if (oldSlide != this.currentSlide) { setTimeout(function(){ jQuery(".ewd-ulb-slide[data-slideindex='" + oldSlide + "']").removeClass('ewd-ulb-active-slide ewd-ulb-old-active-slide'); }, 500); } } jQuery(".ewd-ulb-slide-thumbnail[data-slideindex='" + this.currentSlide + "']").addClass('ewd-ulb-active-thumbnail'); jQuery(".ewd-ulb-slide[data-slideindex='" + this.currentSlide + "']").addClass('ewd-ulb-active-slide ewd-ulb-image-displaying'); var slideNumber = this.currentSlide + 1; jQuery(".ewd-ulb-current-count-indicator").each(function() {jQuery(this).html(slideNumber);}); setTimeout(function(){ jQuery('.ewd-ulb-slide').removeClass('ewd-ulb-transition-next ewd-ulb-transition-previous'); }, 500); lightbox.resizeOverlay(); lightbox.setDownloadLinks(); }, selectThumbnails: function() { var gallery = this.getCurrentGallery(); jQuery('.ewd-ulb-slide-thumbnail').addClass('ewd-ulb-thumbnail-hidden'); jQuery('.ewd-ulb-slide-thumbnail[data-ulbGallery="' + gallery + '"]').removeClass('ewd-ulb-thumbnail-hidden'); }, getCurrentGallery: function() { var gallery = ""; var currentSlide = this.currentSlide; jQuery(this.elements).each(function(index, element) { if (index == currentSlide) {gallery = element.gallery;} }); return gallery; }, resizeOverlay: function() { var imgWidth = jQuery(".ewd-ulb-active-slide.ewd-ulb-image-displaying img").first().width(); var imgHeight = jQuery(".ewd-ulb-active-slide.ewd-ulb-image-displaying img").first().height(); var containerWidth = jQuery(".ewd-ulb-active-slide.ewd-ulb-image-displaying").first().width(); var containerHeight = jQuery(".ewd-ulb-active-slide.ewd-ulb-image-displaying").first().height(); //alert("imageWidth:"+ imgWidth+"imageHeight:"+ imgHeight + "containerWidth:"+ containerWidth+ "containerHeight:" + containerHeight ); var marginWidth = (containerWidth - imgWidth) / 2; var TwentyConHeight = jQuery(".twentytwenty-container").height(); var TwentyConWidth = jQuery(".twentytwenty-container").width(); jQuery(".ewd-ulb-slide-overlay").css('width', imgWidth + 'px'); jQuery(".ewd-ulb-slide-overlay").css('margin', '0px ' + marginWidth + 'px'); //if the image is a curtain slider (ONLY WORKS 1ST TIME) if(jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').length > 0) { if(imgWidth==0 && imgHeight==0)//openeing after CloseLightbox { return; } else if(imgWidth!=TwentyConWidth || imgHeight!=containerHeight) // 1st time no wrapping { jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').css('margin-left',marginWidth + 'px'); jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').css('width',imgWidth + 'px'); jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').css('height',containerHeight +'px'); //jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').css('height',imgHeight +'px'); if(!jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-wrapper').length > 0) //if twenty twenty is already wrapped { jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.ewd-ulb-slide-img').append(''); jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').twentytwenty(); } } } }, toggleThumbnailBar: function() { jQuery( '.ewd-ulb-bottom-thumbnail-bar, .ewd-ulb-top-thumbnail-bar, .ewd-thumbnail-toggle-down, .ewd-thumbnail-toggle-up' ).toggleClass( 'ewd-ulb-thumbnail-bar-hidden' ); jQuery( '.ewd-thumbnail-toggle-down, .ewd-thumbnail-toggle-up' ).toggleClass( 'ewd-ulb-hidden' ); }, toggleAutoplay: function() { if (this.settings.autoplay) {this.stopAutoplay();} else {this.startAutoplay();} }, startAutoplay: function() { if (this.interval) {clearInterval(this.interval);} this.settings.autoplay = true; this.interval = setInterval(function() { lightbox.nextSlide(); }, this.settings.autoplay_interval); }, stopAutoplay: function() { this.settings.autoplay = false; clearInterval(this.interval); }, ZoomOut: function() { if (this.settings.zoomLevel == 2) {this.zoomOne();} else if (this.settings.zoomLevel == 1) {this.noZoom();} this.removeFullSize(); }, toggleZoom: function() { if (this.settings.zoomLevel == 0) {this.zoomOne();} else if (this.settings.zoomLevel == 1) {this.zoomTwo();} else {this.noZoom();} this.removeFullSize(); }, zoomOne: function() { this.settings.zoomLevel = 1; jQuery('.ewd-ulb-slide').addClass('ewd-ulb-zoom-one'); jQuery('.ewd-ulb-slide').removeClass('ewd-ulb-zoom-two'); }, zoomTwo: function() { this.settings.zoomLevel = 2; jQuery('.ewd-ulb-slide').removeClass('ewd-ulb-zoom-one'); jQuery('.ewd-ulb-slide').addClass('ewd-ulb-zoom-two'); }, noZoom: function() { this.settings.zoomLevel = 0; jQuery('.ewd-ulb-slide').removeClass('ewd-ulb-zoom-one'); jQuery('.ewd-ulb-slide').removeClass('ewd-ulb-zoom-two'); }, fullscreen: function() { if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { jQuery('ewd-ulb-fullscreen').addClass('ewd-ulb-regular_screen'); if (document.documentElement.requestFullscreen) { document.documentElement.requestFullscreen(); } else if (document.documentElement.msRequestFullscreen) { document.documentElement.msRequestFullscreen(); } else if (document.documentElement.mozRequestFullScreen) { document.documentElement.mozRequestFullScreen(); } else if (document.documentElement.webkitRequestFullscreen) { document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); } } else { jQuery('ewd-ulb-fullscreen').removeClass('ewd-ulb-regular_screen'); if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } } }, toggleFullSize: function() { this.noZoom(); if (this.settings.fullsize) {this.removeFullSize();} else {this.goFullSize();} }, goFullSize: function() { var elem = jQuery('.ewd-ulb-active-slide .ewd-ulb-slide-img img')[0]; if(jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').length > 0) // If it is a curtain slider just return { return; } if (!elem.fullscreenElement && !elem.mozFullScreenElement && !elem.webkitFullscreenElement && !elem.msFullscreenElement ) { jQuery('ewd-ulb-fullscreen').addClass('ewd-ulb-regular_screen'); if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(); } } }, removeFullSize: function() { jQuery('.ewd-ulb-slide').removeClass('ewd-ulb-fullsize-image'); this.settings.fullsize = false; }, setDownloadLinks: function() { jQuery('.ewd-ulb-download-link').attr('href', jQuery('.ewd-ulb-active-slide div img').attr('src')); }, }); jQuery(document).ready(function($) { if (typeof ewd_ulb_php_data == "undefined") { ewd_ulb_php_data = []; } lightbox = new UltimateLightbox(ewd_ulb_php_data); jQuery('.ewd-ulb-lightbox, .ewd-ulb-open-lightbox').on('click', function(event) { if (jQuery(event.currentTarget).hasClass('ewd-ulb-lightbox')) { lightbox.currentSlide = jQuery(event.currentTarget).data('slideIndex'); } else { lightbox.setCurrentSlide(event.currentTarget); } lightbox.toggle(); event.preventDefault(); }); if (jQuery('.ewd-ulb-lightbox, .ewd-ulb-lightbox-noclick-image').length) { EWD_ULB_Add_Lightbox_HTML(lightbox); jQuery('.ewd-ulb-slide-container').on('click.background', function(event) { if ( event.toElement !== undefined && ( event.toElement.nodeName == "IMG" || event.toElement.nodeName == "iframe" || ! ewd_ulb_php_data.background_close || event.toElement.className != "ewd-ulb-slide-img" ) ) {return;} //alert(event.toElement.className); lightbox.toggle(); }); jQuery('.ewd-ulb-slide-control-next').on('click.next', function() { lightbox.noZoom(); lightbox.stopAutoplay(); lightbox.nextSlide(); }); jQuery('.ewd-ulb-slide-control-previous').on('click.prev', function() { lightbox.noZoom(); lightbox.stopAutoplay(); lightbox.previousSlide(); }); //Wrong Interpretation - must be modified so the image move like a carousel jQuery('.ewd-thumbnail-scroll-button-left').on('click.prev', function() { lightbox.noZoom(); lightbox.stopAutoplay(); }); jQuery('.ewd-thumbnail-scroll-button-right').on('click.next', function() { lightbox.noZoom(); lightbox.stopAutoplay(); }); jQuery('.ewd-ulb-slide-thumbnail').on('click.thumbnail', function() { var slideIndex = jQuery(this).data("slideindex"); lightbox.noZoom(); lightbox.stopAutoplay(); lightbox.goToSlide(slideIndex); }); jQuery( '.ewd-thumbnail-toggle' ).on( 'click.thumbnail_toggle', function() { lightbox.toggleThumbnailBar(); }); jQuery(window).on('resize', function() { lightbox.resizeOverlay() }); jQuery('.ewd-ulb-exit').on('click.exit', function() { lightbox.toggle(); }); jQuery('.ewd-ulb-autoplay').on('click.autoplay', function() { lightbox.toggleAutoplay(); }); jQuery('.ewd-ulb-zoom').on('click.zoom', function() { lightbox.toggleZoom(); }); jQuery('.ewd-ulb-zoom_out').on('click.zoom_out', function() { lightbox.ZoomOut(); }); jQuery('.ewd-ulb-fullsize').on('click.fullsize', function() { lightbox.toggleFullSize(); }); jQuery('.ewd-ulb-fullscreen').on('click.zoom_out', function() { lightbox.fullscreen(); }); jQuery('.ewd-ulb-download').wrap(''); if (lightbox.settings.keyboard_controls) { jQuery(document).on('keyup', function(e) { if (e.which == 27) {lightbox.closeLightbox();} if (e.which == 37) { lightbox.noZoom(); lightbox.stopAutoplay(); lightbox.previousSlide(); } if (e.which == 39) { lightbox.noZoom(); lightbox.stopAutoplay(); lightbox.nextSlide(); } }); } //LISTENERS jQuery(".ewd-ulb-slide-area").on("touchstart", function(event) { slider.longTouch = false; setTimeout(function() { // Since the root of setTimout is window we can’t reference this. That’s why this variable says window.slider in front of it. window.slider.longTouch = true; }, 250); // Get the original touch position. slider.touchstartx = event.originalEvent.touches[0].pageX; // if(jQuery('.animate').length>0) // { // jQuery('.animate').removeClass('animate'); // } }); jQuery(".ewd-ulb-slide-area").on("touchmove", function(event) { slider.touchmovex = event.originalEvent.touches[0].pageX; //console.log("Index: " + slider.index); // Calculate distance to translate holder.3 slider.slideWidth = jQuery(".ewd-ulb-slide-container").width(); slider.movex = (slider.touchstartx - slider.touchmovex); //console.log("Slider Move:" + slider.movex); // Defines the speed the images should move at. var panx = 100-slider.movex/6; // If it is a curtain slider just return if(jQuery('.ewd-ulb-active-slide.ewd-ulb-image-displaying').find('.twentytwenty-container').length > 0) { return; } if(slider.movex > 0)//swiping forward - this will move the image { if (slider.movex < 600) { // Makes the holder stop moving when there is no more content. jQuery(".ewd-ulb-slide-container").css('transform','translate3d(-' + slider.movex + 'px,0,0)'); } if (panx < 100) { // Corrects an edge-case problem where the background image moves without the container moving. jQuery(".ewd-ulb-image-displaying img").css('transform','translate3d(-' + panx + 'px,0,0)'); } } else if (slider.movex < 0)//swiping backward - this will move the image { if (slider.movex < 600) { // Makes the holder stop moving when there is no more content. jQuery(".ewd-ulb-slide-container").css('transform','translate3d(' + Math.abs(slider.movex)+ 'px,0,0)'); } if (panx < 100) { // Corrects an edge-case problem where the background image moves without the container moving. jQuery(".ewd-ulb-image-displaying img").css('transform','translate3d(' + Math.abs(panx) + 'px,0,0)'); } } }); jQuery(".ewd-ulb-slide-area").on("touchend", function(event) { // Calculate the distance swiped. var absMove = Math.abs(slider.movex); // Calculate the index. All other calculations are based on the index. if (absMove > slider.slideWidth/2 || slider.longTouch === false) { //change image if(slider.movex < 0) { lightbox.previousSlide(); // leftswipe - change to previous image } else if( slider.movex > 0) { lightbox.nextSlide(); // rightswipe - change to next image } } //Because the boxes have moved from original location,we need to bring them back jQuery(".ewd-ulb-slide-container").css('transform','none'); jQuery(".ewd-ulb-image-displaying img").css('transform','none'); }); } }); function EWD_ULB_Add_Lightbox_HTML(lightbox) { var Custom_CSS = ''; Custom_CSS += lightbox.settings.styling_options; var Top_Toolbar_HTML = '
'; Top_Toolbar_HTML += '
' + EWD_ULB_Add_Controls(lightbox.settings.controls.top_left_controls, lightbox.maxSlide) + '
'; Top_Toolbar_HTML += '
' + EWD_ULB_Add_Controls(lightbox.settings.controls.top_right_controls, lightbox.maxSlide) + '
'; Top_Toolbar_HTML += '
'; var Top_Thumbnail_Bar_HTML = '
'; Top_Thumbnail_Bar_HTML += '
a
'; Top_Thumbnail_Bar_HTML += '
b
'; Top_Thumbnail_Bar_HTML += '
'; if (lightbox.settings.show_thumbnails == "top") {Top_Thumbnail_Bar_HTML += EWD_ULB_Thumbnails_HTML(lightbox.elements);} Top_Thumbnail_Bar_HTML += '
'; Top_Thumbnail_Bar_HTML += '
'; if ( lightbox.settings.show_thumbnail_toggle && lightbox.settings.show_thumbnails == "top" ) { Top_Thumbnail_Bar_HTML += '
'; } var Slide_Area_HTML = '
'; Slide_Area_HTML += '
' + lightbox.settings.ulb_arrow + '
'; Slide_Area_HTML += '
'; jQuery(lightbox.elements).each(function(index, value){ Slide_Area_HTML += '
'; Slide_Area_HTML += '
'; if (this.video == "youtube") { Slide_Area_HTML += '' } else { Slide_Area_HTML += ''; } Slide_Area_HTML += '
'; if ((this.title != undefined && this.title != "") || (this.description != undefined && this.description != "")) { Slide_Area_HTML += '
'; if (this.title != undefined && this.title != "") {Slide_Area_HTML += '
' + this.title + '
';} if (this.description != undefined && this.description != "") {Slide_Area_HTML += '
' + this.description + '
';} Slide_Area_HTML += '
'; } Slide_Area_HTML += '
'; }); Slide_Area_HTML += '
'; Slide_Area_HTML += '
' + String.fromCharCode(lightbox.settings.ulb_arrow.charCodeAt(lightbox.settings.ulb_arrow.length-1)+1) + '
'; Slide_Area_HTML += '
'; var Bottom_Thumbnail_Bar_HTML = ''; if ( lightbox.settings.show_thumbnail_toggle && lightbox.settings.show_thumbnails == "bottom" ) { Bottom_Thumbnail_Bar_HTML += '
'; } Bottom_Thumbnail_Bar_HTML += '
'; Bottom_Thumbnail_Bar_HTML += '
a
'; Bottom_Thumbnail_Bar_HTML += '
b
'; Bottom_Thumbnail_Bar_HTML += '
'; if (lightbox.settings.show_thumbnails == "bottom") {Bottom_Thumbnail_Bar_HTML += EWD_ULB_Thumbnails_HTML(lightbox.elements);} Bottom_Thumbnail_Bar_HTML += '
'; Bottom_Thumbnail_Bar_HTML += '
'; var Bottom_Toolbar_HTML = '
'; Bottom_Toolbar_HTML += '
' + EWD_ULB_Add_Controls(lightbox.settings.controls.bottom_left_controls, lightbox.maxSlide) + '
'; Bottom_Toolbar_HTML += '
' + EWD_ULB_Add_Controls(lightbox.settings.controls.bottom_right_controls, lightbox.maxSlide) + '
'; Bottom_Toolbar_HTML += '
'; var HTML = ''; HTML += '"; jQuery('body').append(HTML); } function EWD_ULB_Thumbnails_HTML(slides) { var Slide_HTML = ''; var prev_gallery ; jQuery(slides).each(function(index, value) { // if(this.gallery==undefined) // If youtube video is added it will be placed in the last // { // //alert(prev_gallery); // //Slide_HTML += '
'; // } // else // { Slide_HTML += '
'; //} if (this.video == "youtube") { Slide_HTML += ''; } else { Slide_HTML += ''; } Slide_HTML += '
'; prev_gallery = this.gallery; }); return Slide_HTML; } function EWD_ULB_Add_Controls(controls, maxSlide) { var Controls_HTML = ''; jQuery(controls).each(function() { if (this == 'slide_counter') {Controls_HTML += '
1/' + (maxSlide + 1) + '
';} else {Controls_HTML += '
' + lightbox.settings.ulb_icon_set + '
';} }); return Controls_HTML; } /**************************************** THUMBNAIL SCROLLING ****************************************/ jQuery(document).ready(function($){ $('.ewd-ulb-bottom-thumbnail-bar').each(function(){ var thisThumbBar = $(this); var numberOfThumbs = thisThumbBar.find('.ewd-ulb-slide-thumbnail').length; var widthOfThumbsInside = numberOfThumbs * 144; thisThumbBar.find('.ewd-ulb-thumbnails-inside').css('width', widthOfThumbsInside+'px'); thisThumbBar.find('.ewd-thumbnail-scroll-button-right').click(function(){ var widthOfThumbs = thisThumbBar.find('.ewd-ulb-bottom-thumbnails').width(); if(widthOfThumbs >= widthOfThumbsInside){ var rightClickStop = 0; } else{ var rightClickStop = (widthOfThumbsInside * -1) + widthOfThumbs; } var thumbsInsideLeft = thisThumbBar.find('.ewd-ulb-thumbnails-inside').position().left; if(thumbsInsideLeft != rightClickStop){ thisThumbBar.find('.ewd-ulb-thumbnails-inside').css('left', '-=144'); } }); thisThumbBar.find('.ewd-thumbnail-scroll-button-left').click(function(){ var leftClickStop = 0; var thumbsInsideLeft = thisThumbBar.find('.ewd-ulb-thumbnails-inside').position().left; if(thumbsInsideLeft != leftClickStop){ thisThumbBar.find('.ewd-ulb-thumbnails-inside').css('left', '+=144'); } }); }); $('.ewd-ulb-top-thumbnail-bar').each(function(){ var thisTopThumbBar = $(this); var numberOfTopThumbs = thisTopThumbBar.find('.ewd-ulb-slide-thumbnail').length; var widthOfTopThumbsInside = numberOfTopThumbs * 144; thisTopThumbBar.find('.ewd-ulb-thumbnails-inside').css('width', widthOfTopThumbsInside+'px'); thisTopThumbBar.find('.ewd-thumbnail-scroll-button-right').click(function(){ var widthOfTopThumbs = thisTopThumbBar.find('.ewd-ulb-top-thumbnails').width(); if(widthOfTopThumbs >= widthOfTopThumbsInside){ var rightClickStopTop = 0; } else{ var rightClickStopTop = (widthOfTopThumbsInside * -1) + widthOfTopThumbs; } var thumbsInsideLeftTop = thisTopThumbBar.find('.ewd-ulb-thumbnails-inside').position().left; if(thumbsInsideLeftTop != rightClickStopTop){ thisTopThumbBar.find('.ewd-ulb-thumbnails-inside').css('left', '-=144'); } }); thisTopThumbBar.find('.ewd-thumbnail-scroll-button-left').click(function(){ var leftClickStopTop = 0; var thumbsInsideLeftTop = thisTopThumbBar.find('.ewd-ulb-thumbnails-inside').position().left; if(thumbsInsideLeftTop != leftClickStopTop){ thisTopThumbBar.find('.ewd-ulb-thumbnails-inside').css('left', '+=144'); } }); }); }); ////////////////////////////////////// /////MARGIN OF VIDEOS IN LIGHTBOX///// ////////////////////////////////////// jQuery(document).ready(function($) { $('.ewd-ulb-slide-img').each(function() { var thisSlideImg = $(this); //thisSlideImg.slick(); if(thisSlideImg.find('iframe').length > 0) { //thisSlideImg.find('iframe').css({"position":"absolute","top":"0px","left":"0px","display":"block"}) thisSlideImg.find('iframe').css({"display":"inline-block"}) //thisSlideImg.find('iframe').css({"position":"absolute","centre":"both","float":"left","display":"block"}) //var thisSlideIframeHalfHeight = ( ( thisSlideImg.find('iframe').height() ) / 2 ) * -1; //thisSlideImg.find('iframe').css('margin-top', thisSlideIframeHalfHeight+'px'); //thisSlideImg.append(''); // To remove the height above the videos } }); //$('.ewd-ulb-slide-container').slick(); }); // source --> http://ashoksawhney.com/wp-content/plugins/ultimate-lightbox/assets/js/jquery.mousewheel.min.js?ver=1 /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * * Version: 3.1.12 * * Requires: jQuery 1.2.2+ */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});